package com.example.bbgds.test;

import android.app.Service;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.os.Messenger;
import android.os.RemoteException;
import android.util.Log;

/**
 * Created by bbgds on 2016/5/17.
 */
public class RemoteService extends Service {
    public static final int GET_RESULT = 1;

    @Override
    public void onCreate() {
        Log.e("zhu","onCreate");
    }
    private final Messenger mMessenger = new Messenger(new Handler() {
        private int remoteInt = 1;//返回到进程A的值
        @Override
        public void handleMessage(Message msg) {
            if (msg.what == GET_RESULT) {
                Log.e("zhu", "RemoteService recevie");
                try{
                    Bundle bundle = msg.getData();
                    if(bundle != null){
                        Log.e("zhu", bundle.getString("ssss"));
                        Log.e("zhu", "ss=" + bundle.getParcelable("vvv"));
                    }
                }catch (Exception e){
                    Log.e("zhu", "RemoteService eroor", e);
                }

            } else {
                super.handleMessage(msg);
            }
        }
    });

    @Override
    public IBinder onBind(Intent intent) {
        return mMessenger.getBinder();
    }
}
